package com.cv.platform.controller.platform.search;

import com.cv.framework.common.pojo.PageResult;
import com.cv.framework.common.pojo.Result;
import com.cv.platform.controller.platform.search.vo.CvVideoSearchReqVO;
import com.cv.platform.controller.platform.video.vo.CvVideoItemRespVO;
import com.cv.platform.service.search.CvVideoSearchService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import java.util.List;

/**
 * 视频平台 - 视频搜索控制层
 *
 * @author Charles_XDXD
 */
@Tag(name = "视频平台 - 视频搜索控制层")
@RestController
@RequestMapping("/platform/video")
public class CvVideoSearchController {

    @Resource
    private CvVideoSearchService cvVideoSearchService;

    @GetMapping("search")
    @Operation(summary = "通过 ES 搜索引擎查询视频")
    @PermitAll
    public Result<PageResult<CvVideoItemRespVO>> searchVideo(CvVideoSearchReqVO reqVO) {
        return Result.success(cvVideoSearchService.searchVideo(reqVO));
    }

    @GetMapping("hotSearch")
    @Operation(summary = "获取热门搜索")
    @PermitAll
    public Result<List<String>> getHotSearch() {
        return Result.success(cvVideoSearchService.getHotSearch());
    }

}
